<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head>
	<th:block th:include="include :: header('修改')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-channel-edit" th:object="${column}">
           <input name="id" type="hidden" th:field="*{id}" />
			<input id="treeId" name="pid" type="hidden" th:field="*{pid}" />
            <div class="form-group">
				<label class="col-sm-3 control-label ">上级栏目：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" onclick="selectChnanelTree()" id="treeName" readonly="true" th:field="*{parentName}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" id="name" name="name" th:field="*{name}">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">是否指定链接：</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('system_content_yes_no')}">
						<input type="radio" th:id="${dict.dictCode}" name="customLink" th:value="${dict.dictValue}" th:field="*{customLink}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>

				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">链接地址:</label>
				<div class="col-sm-8">

					<input id="customLinkUrl" name="customLinkUrl" th:field="*{customLinkUrl}"  class="form-control" type="text">
				</div>
			</div>
						
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目类型:</label>
				<div class="col-sm-8">
					<select id="businessType" name="type" class="form-control m-b" th:with="type=${@dict.getType('system_content_column_type')}">
	                    <option th:each="dict : ${type}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}" th:field="*{type}"></option>
	                </select>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">是否在主页显示:</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('system_content_yes_no')}">
						<input type="radio" th:id="${dict.dictCode}" name="isIndex" th:value="${dict.dictValue}" th:field="*{isIndex}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>

				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">是否导航栏目:</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('system_content_yes_no')}">
						<input type="radio" th:id="${dict.dictCode}" name="isTopNav" th:value="${dict.dictValue}" th:field="*{isTopNav}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>

				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">是否是推荐栏目:</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('system_content_yes_no')}">
						<input type="radio" th:id="${dict.dictCode}" name="recommend" th:value="${dict.dictValue}" th:field="*{recommend}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>

				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目状态:</label>
				<div class="col-sm-8">
					<div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
						<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>

				</div>
			</div>
			
			<div class="form-group">
				<label class="col-sm-3 control-label">栏目序号:</label>
				<div class="col-sm-8">
					<input id="orders" name="orders" class="form-control" type="text" th:field="*{orders}">
				</div>
			</div>
			<div class="form-group">
				<div class="form-control-static col-sm-offset-9">
					<button type="submit" class="btn btn-primary">提交</button>
					<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/content/column";
		$("#form-channel-edit").validate({
			rules:{
				name:{
					required:true,
					remote: {
		                url: prefix + "/checkChannelNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"id": function() {
		                        return $("input[name='id']").val();
		                    },
		        			"name": function() {
		                        return $("input[name='name']").val();
		                    }
		                },
		                dataFilter: function(data, type) {
		                    if (data == "0") return true;
		                    else return false;
		                }
		            }
				},
				orderNum:{
					required:true,
					digits:true
				},
			},
			messages: {
		        "name": {
		            remote: "栏目已经存在"
		        }
		    },
			submitHandler:function(form){
				$.operate.save(prefix + "/save", $('#form-channel-edit').serialize());
			}
		});
		
		/*栏目管理-新增-选择父部门树*/
		function selectChnanelTree() {
		    var id = $("#treeId").val();
			var url = prefix + "/selectChannelTree/" + id;
			$.modal.open("选择栏目", url, '380', '380');
		}
	</script>
</body>
</html>
